﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Moneymatters
{
    public partial class NarrationDialog : Form
    {
        //public Narration()
        //{
        //    InitializeComponent();
        //}

        public NarrationDialog(string existingText, bool isReadOnly)
        {
            InitializeComponent();
            this.textBoxNarration.Text = existingText;
            
            if (isReadOnly)
            {
                this.textBoxNarration.Enabled = false;
                this.buttonSaveNarration.Visible = false;
                this.Text = "Narration";
                this.StartPosition = FormStartPosition.CenterParent;
            }

            this.Shown += NarrationDialog_Shown;
        }

        void NarrationDialog_Shown(object sender, EventArgs e)
        {
            this.textBoxNarration.Focus();

            if (!string.IsNullOrEmpty(this.textBoxNarration.Text))
            {
                this.textBoxNarration.Select(this.textBoxNarration.Text.Length, 1);
            }
            else
            {
                this.textBoxNarration.Select(0, 0);
            }
        }

        public string GetNarration()
        {
            return this.textBoxNarration.Text.Trim();
        }

        private void buttonSaveNarration_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
